<script type="text/javascript">
var _betmin = {betmin};
var renewRateTimeObj = "";    // 更新赔率物件 跨页面
var renewRateTime = "30000";  // 更新赔率秒数 跨页面
var _gametype = "{gametype}";  // 跨页面
function leftPar(v)
{
	if(parseInt(v)<=9)
		return "0"+v;
	else
		return v;	
}
$(function(){ 
  // 预设显示的下注模式 快速/勾选
  $("input#disk").attr("value",$("select#slcDisk option:selected").val());
  //if($("input:hidden#timebtnType").val() == "text"){$("input:button#betByTextMoney").hide();}else{$("input:button#betByCheckBox").hide();}
  
  // 显示现在时间
  $("span#showNowTime").showNowTime();
  
  // 切换勾选
  $("input:button#betByCheckBox").bind('click',function(){
    $().timebtnTypeToCheckbox();
  });
  // 切换快速
  $("input:button#betByTextMoney").bind('click',function(){$().timebtnTypeText();});
  
  // 「转送」
  $("input:button#btnSetMyNum").bind('click', function(){
    var setMomney = $("input:text#setMomney").val();
    if(setMomney< 1){
      $().showMyMsgBox("请於「金额」右侧之文字方块中输入要转送之金额");
      $("input:text#setMomney").focus();
      return false;
    }else if(setMomney< _betmin){
      $().showMyMsgBox("下注金额不能小於最低下注额("+_betmin+"元)");
      $("input:text#setMomney").focus();
      return false;
    }else{
      $("input:text[name^='r'][value='*']").val(setMomney);
      $("input:text#setMomney").val("");
    } 
  });
  
  // 送出表单
  $("form").submit(function() {
    switch($("input:hidden#timebtnType").val()){
      case "text": //text
      if($("input:text[name^='r'][value!='']").not("[value='*']").size() < 1){
       $().showMyMsgBox("请在文字方块中填入要下注的金额；<br />或使用「转送」钮将「*」字转为金额值");
        return false;
      }
      break;
      
      case "checkbox": // checkbox
      if($("input:checkbox[name^='r']:checked").size() < 1){
        $().showMyMsgBox("请勾选要下注的内容");
        return false;
      }else if($("input:text#setMomney").val()< 1){
        $().showMyMsgBox("请於「金额」右侧之文字方块中输入下注金额");
        $("input:text#setMomney").focus();
        return false;
      }else if($("input:text#setMomney").val()< _betmin){
        $().showMyMsgBox("下注金额不能小於最低下注额("+_betmin+"元)");
        $("input:text#setMomney").focus();
        return false;
      }else {
        $("input:checkbox[name^='r']:checked").val($("input:text#setMomney").val())
      } 
      break;
    }
    $("form input:submit").add("form input:reset").attr("disabled","true");
    $("input#disk").attr("value",$("select#slcDisk option:selected").val());
    return true;
  });
  
  $("input:button").hover(
      function() {this.style.color='#0000FF';}
      , function() {this.style.color='';}
  );

});


// 切换勾选
$.fn.timebtnTypeToCheckbox = function(){
	mysetcookie("timebtnType","checkbox",1);
  $("input:hidden#timebtnType").val("checkbox");
  $("input:text[name^='r']").each(function(){
	var o=$(this).parent();
    o.html("<input type=\"checkbox\" value=\"1\" name=\""+$(this).attr("name")+"\"  style=\"display:none\"/>");
  	o.bind("click",function(e){
		var inpu=$(this).find("input");
		if(inpu.attr("checked"))
		{
			$(this).removeClass("k1");	
			//$(this).prev().removeClass("k1");
			inpu.attr("checked",false);
		}
	  	else
		{
			//$(this).prev().addClass("k1");
			$(this).addClass("k1");	
			inpu.attr("checked",true);
		}
	});
  });
  $("input:button#betByCheckBox").addClass("btn_on");
  $("input:button#betByTextMoney").removeClass("btn_on");
  //$("input:button#betByCheckBox").hide();
  //$("input:button#betByTextMoney").show();
  $("input:button#btnSetMyNum").attr("disabled","true");
};

// 切换快速
$.fn.timebtnTypeText = function(){
	mysetcookie("timebtnType","text",1);
  $("input:hidden#timebtnType").val("text");
  $("input:checkbox[name^='r']").each(function(){
	var o=$(this).parent();
    o.html("<input type=\"text\" value=\"\" name=\""+$(this).attr("name")+"\" size=\"3\" />");
	o.removeClass("k1");
	o.prev().removeClass("k1");
	o.unbind("click");
  });
  $("input:button#betByTextMoney").addClass("btn_on");
  $("input:button#betByCheckBox").removeClass("btn_on");
  //$("input:button#betByTextMoney").hide();
  //$("input:button#betByCheckBox").show();
  $("input:button#btnSetMyNum").removeAttr("disabled");
};


// 显示时间
var _now = new Date(1000 * {timetamp});
var _timestap = {timetamplimit};
var _refstap=30;
$.fn.showNowTime = function(){
  var thisObj = $(this);
  var str = "";
  if(_timestap >=0){
    timediff = _timestap;
    days = Math.floor(timediff / (86400));   // 60 * 60 * 24
  	timediff -= days * (86400);
  	hours = Math.floor(timediff / (3600));  // 60 * 60
  	timediff -= hours * (3600);	
  	mins = Math.floor(timediff / (60));
  	timediff -= mins * (60);	
  	secs = Math.floor(timediff);
    str += "<span style='margin-right:10px'><div style='float:left;width:150px'>距离封盘：";
    if (days > 0 ) str += "<b>" + leftPar(days) + "</b> 天 ";
    if (hours > 0) str += "<b>" + leftPar(hours) + "</b>:";
    if (mins > 0) str += "<b>" + leftPar(mins) + "</b>:";
    str += "<b>" + leftPar(secs) + "</b></div><div style='float:left;width:150px'>距离开奖：";
	//
	timediff2=_timestap+60;
	days = Math.floor(timediff2 / (86400));   // 60 * 60 * 24
  	timediff2 -= days * (86400);
  	hours = Math.floor(timediff2 / (3600));  // 60 * 60
  	timediff2 -= hours * (3600);	
  	mins = Math.floor(timediff2 / (60));
	timediff2 -= mins * (60);	
  	secs = Math.floor(timediff2);
	if (days > 0 ) str += "<b>" + leftPar(days) + "</b> 天 ";
    if (hours > 0) str += "<b>" + leftPar(hours) + "</b>:";
    if (mins > 0) str += "<b>" + leftPar(mins) + "</b>:";
	str += "<b>" + leftPar(secs) + "</b></div><div style='float:left;width:50px;text-align:right;'>"+leftPar(_refstap)+"秒</div></span>";
	_refstap--;
	if(_refstap==0) _refstap=30;
    _timestap-=1;
  }else{
    str += "<font color=red><b>【{gametypeStr}】已经截止下注！</b></font>";
    location.reload();
  }
  $(this).html(str);
  _now.setTime(_now.getTime() + 1000);
  setTimeout(function(){$(thisObj).showNowTime();},1000);
};

// 显示讯息方块(取代alert 因alert会使目前时间与截止下注时间暂时停止计算)
$.fn.showMyMsgBox = function(msg){
  $("div#show3dmsg").html("<span class=\"error3d\">"+msg+"</span><br /><input type=\"button\" align=\"center\" id=\"btnOkMsg\" class=\"btnchoice\" value=\"确定\" onclick=\"javascript:$().closeMyMsgBox();\" />");
  $("div#show3dmsg").addClass("show3dmsg").show();
};

$.fn.closeMyMsgBox = function(){
 $("div#show3dmsg").removeClass("show3dmsg").hide();
};

//  更新率赔率禁止使用
$.fn.disAreaObj = function(){
 $("select#slcDisk").attr("disabled","disabled");
 $("input:button#betByCheckBox").attr("disabled","disabled");
 $("input:button#betByTextMoney").attr("disabled","disabled");
};

$.fn.redisAreaObj = function(){
 $("select#slcDisk").removeAttr("disabled");
 $("input:button#betByCheckBox").removeAttr("disabled");
 $("input:button#betByTextMoney").removeAttr("disabled");
};

</script>

<style type="text/css">
.show3dmsg{
  text-align:center;
  z-index: 1;
  position: absolute;
  top: 40%;
  border: 4px ridge #FFB85D;
  background-color: #515152;
  padding: 20px 10px;
  width: 100%;

}
.alert1{
  text-align:center;
}

</style>


<div id="show3dmsg"></div>
<div class="headtitle title0_b bgImg_{gametype}">
<span class="head1"  style="margin-top:2px">&nbsp;<font color="#3F733E"><b>{round}</b></font> 期&nbsp;&nbsp;<font color="#0000ff"><b>{playtypeCh}</b></font>&nbsp;</span>
<span id="spanChgBetBtn" class="head1">
<input type="button" value="勾选" id="betByCheckBox" name="betByCheckBox" class="btn_r" />
<input type="button" value="快速" id="betByTextMoney" name="betByTextMoney" class="btn_r btn_on" />
</span>
<span class="head1">
&nbsp;&nbsp;&nbsp;
<select name="disk" id="slcDisk">{diskBetSlcList}</select>&nbsp;
</span>
<span id="showNowTime" class="head2"  style="margin-top:2px"></span>
<br style="float:clear" />
</div>   